﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Net.Mail;
using System.Text;

/// <summary>
/// Summary description for Common_task
/// </summary>
public class Common_task
{



    public static bool check_type=true;
    public string MaNgauNhien_So(int codeCount)
    {
        string allChar = "0,1,2,3,4,5,6,7,8,9";
        string[] allCharArray = allChar.Split(',');
        string randomCode = "";
        int temp = -1;
        Random rand = new Random();
        for (int i = 0; i < codeCount; i++)
        {
            if (temp != -1)
            {
                rand = new Random(i * temp * ((int)DateTime.Now.Ticks));
            }
            int t = rand.Next(10);
            if (temp != -1 && temp == t)
            {
                return MaNgauNhien_So(codeCount);
            }
            temp = t;
            randomCode += allCharArray[t];
        }
        return randomCode;
    }
    public static bool check_dauphay(string inputtext)
    {

            if (inputtext.Contains(','))
                return true;
            return false;
        
        
     
        
    }
    public static bool check_kytu(string inputtext)
    {
        bool flag = false;
        try
        {
            decimal solieu = Convert.ToDecimal(inputtext);
            
        }
        catch (Exception ex)
        {
            flag = true;
        }
        return flag;


    }

    /// <summary>
    /// Hàm này trả về chuỗi Password ngẫu nhiên [a-z], [0-9]
    /// </summary>
    /// <param name="PasswordLength">độ dài mật khẩu</param>
    /// <returns>mật khẩu</returns>
        public static string Gen_pass(int PasswordLength)
    {
	        string _allowedChars = "abcdefghijkmnopqrstuvwxyz0123456789";
        Random randNum = new Random();
	        char[] chars = new char[PasswordLength];
        int allowedCharCount = _allowedChars.Length;
	        for (int i = 0; i < PasswordLength; i++)
	        {
	            chars[i] = _allowedChars[(int)((_allowedChars.Length) * randNum.NextDouble())];
	        }
	        return new string(chars);
	 }
    /// <summary>
    /// hàm tạo MaCoQuan
    /// </summary>
    /// <returns>macoquan:không trùng nhau</returns>
    public string Gen_ID()
    {
        string madonvi = "";
        string machuoi=MaNgauNhien_So(3)+MaNgauNhien_So(3);
        return madonvi =machuoi;
    }
    public void Send_mail(string from,string to,string pass_from)
    {

    }
	
}